﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Resources;
using System.Threading;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace EC2011_hk1_BT7_1041326_1041337_1041373_1041448.MasterPages
{
    public partial class MasterPage : System.Web.UI.MasterPage
    {
        ResourceManager rm;
        
        protected void Page_Load(object sender, EventArgs e)
        {
            //CultureInfo ci;
            //if (Session["Location"] == null)
            //{
            //    Session["Location"] = "vi-VN";
            //}            
            //Thread.CurrentThread.CurrentCulture = new CultureInfo(Session["Location"].ToString());
            //rm = new ResourceManager("Resources.SitMap", System.Reflection.Assembly.Load("App_GlobalResources"));
            //ci = Thread.CurrentThread.CurrentCulture;
            //LoadString(ci);
            //Session["Lang"] = Session["Location"].ToString().Substring(0, 2);
        }

        public void LoadString(CultureInfo ci)
        {
            HyperLinkHome.Text = rm.GetString("Home", ci);
            HyperLinkProducts.Text = rm.GetString("Products", ci);
            HyperLinkAbout.Text = rm.GetString("About", ci);
            HyperLinkContact.Text = rm.GetString("Contact", ci);
            HyperLinkLang.Text = rm.GetString("Lang", ci);
            HyperLinkAbout1.Text = rm.GetString("About", ci);
            HyperLinkAbout2.Text = rm.GetString("About", ci);
            HyperLinkHome1.Text = rm.GetString("Home", ci);
            HyperLinkProduct1.Text = rm.GetString("Products", ci);
            HyperLinkContact1.Text = rm.GetString("Contact", ci);
            HyperLinkHome2.Text = rm.GetString("Home", ci);
            HyperLinkProduct2.Text = rm.GetString("Products", ci);
            HyperLinkContact2.Text = rm.GetString("Contact", ci);
            LabelMenu.Text = rm.GetString("Menu", ci);
            
        }

        protected void LinkVN_Click(object sender, EventArgs e)
        {
            Session["Location"] = "vi-VN";
            Thread.CurrentThread.CurrentCulture = new CultureInfo(Session["Location"].ToString());
            rm = new ResourceManager("Resources.SitMap", System.Reflection.Assembly.Load("App_GlobalResources"));
            CultureInfo ci = Thread.CurrentThread.CurrentCulture;
            LoadString(ci);
            Session["Lang"] = Session["Location"].ToString().Substring(0, 2);
        }

        protected void LinkEN_Click(object sender, EventArgs e)
        {
            Session["Location"] = "en-US";
            Thread.CurrentThread.CurrentCulture = new CultureInfo(Session["Location"].ToString());
            rm = new ResourceManager("Resources.SitMap", System.Reflection.Assembly.Load("App_GlobalResources"));
            CultureInfo ci = Thread.CurrentThread.CurrentCulture;
            LoadString(ci);
            Session["Lang"] = Session["Location"].ToString().Substring(0, 2);
        }

        
    }
}
